package com.ruoyi.web.controller.fs;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.fs.domain.FsCourtAddressMapping;
import com.ruoyi.fs.service.IFsCourtAddressMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 法院地址匹配Controller
 *
 * @author hero
 * @date 2024-12-18
 */
@RestController
@RequestMapping("/fs/courtmapping")
public class FsCourtAddressMappingController extends BaseController
{
    @Autowired
    private IFsCourtAddressMappingService fsCourtAddressMappingService;

    /**
     * 查询法院地址匹配列表
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourtAddressMapping fsCourtAddressMapping)
    {
        startPage();
        List<FsCourtAddressMapping> list = fsCourtAddressMappingService.selectFsCourtAddressMappingList(fsCourtAddressMapping);
        return getDataTable(list);
    }

    /**
     * 导出法院地址匹配列表
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:export')")
    @Log(title = "法院地址匹配", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsCourtAddressMapping fsCourtAddressMapping)
    {
        List<FsCourtAddressMapping> list = fsCourtAddressMappingService.selectFsCourtAddressMappingList(fsCourtAddressMapping);
        ExcelUtil<FsCourtAddressMapping> util = new ExcelUtil<FsCourtAddressMapping>(FsCourtAddressMapping.class);
        util.exportExcel(response, list, "法院地址匹配数据");
    }

    /**
     * 获取法院地址匹配详细信息
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fsCourtAddressMappingService.selectFsCourtAddressMappingById(id));
    }

    /**
     * 新增法院地址匹配
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:add')")
    @Log(title = "法院地址匹配", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourtAddressMapping fsCourtAddressMapping)
    {
        return toAjax(fsCourtAddressMappingService.insertFsCourtAddressMapping(fsCourtAddressMapping));
    }

    /**
     * 修改法院地址匹配
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:edit')")
    @Log(title = "法院地址匹配", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourtAddressMapping fsCourtAddressMapping)
    {
        return toAjax(fsCourtAddressMappingService.updateFsCourtAddressMapping(fsCourtAddressMapping));
    }

    /**
     * 删除法院地址匹配
     */
    @PreAuthorize("@ss.hasPermi('fs:courtmapping:remove')")
    @Log(title = "法院地址匹配", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsCourtAddressMappingService.deleteFsCourtAddressMappingByIds(ids));
    }
}
